package com.chaoyong.higo.adapter;

import com.chaoyong.higo.R;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

public class SlidingMenuLeftAdapter extends BaseAdapter {

	private String[] title = { "数码影音", "电脑办公", "智能硬件", "时尚家居", "食品饮料", "新手专区", "任性专区", "其他商品" };
	private int[] imgs = { R.drawable.shumayingyin, R.drawable.diannaobangong, R.drawable.zhinengyingjian,
			R.drawable.shishangjiajv, R.drawable.shipinyinliao, R.drawable.xinshouzhuanqu, R.drawable.renxingzhuanqu,
			R.drawable.qita };
	private Context context;
	private LayoutInflater inflater;

	public SlidingMenuLeftAdapter(Context context) {
		this.context = context;
		inflater = LayoutInflater.from(context);
	}

	@Override
	public int getCount() {
		// TODO Auto-generated method stub
		return imgs.length;
	}

	@Override
	public Object getItem(int position) {
		// TODO Auto-generated method stub
		return imgs[position];
	}

	@Override
	public long getItemId(int position) {
		// TODO Auto-generated method stub
		return position;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		// TODO Auto-generated method stub
		ViewHolder mViewHolder;
		if (convertView == null) {
			convertView = inflater.inflate(R.layout.item_slidingmenu_left, null);
			mViewHolder = new ViewHolder();
			mViewHolder.imageView = (ImageView) convertView.findViewById(R.id.item_slidingmenu_img);
			mViewHolder.titlte = (TextView) convertView.findViewById(R.id.item_slidingmenu_title);
			convertView.setTag(mViewHolder);
		} else {
			mViewHolder = (ViewHolder) convertView.getTag();
		}
		mViewHolder.imageView.setBackgroundResource(imgs[position]);
		mViewHolder.titlte.setText(title[position]);
		return convertView;
	}

	class ViewHolder {
		public ImageView imageView;
		private TextView titlte;
	}
}
